﻿/** \file
* \$Rev: 3 $
* 
* \$Date: 2010-06-20 21:00:41 +0000 (Sun, 20 Jun 2010) $
*
* \$URL: http://fofbrainz.googlecode.com/svn/trunk/MusicBrainz/RankedTrack.cs $
*/

using System;

namespace FofBrainz.MusicBrainz
{
	/// <summary>
	/// A MusicBrainz track, able to be ranked by relevance.
	/// </summary>
	public class RankedTrack : IComparable<RankedTrack>
	{
		/// <summary>The MusicBrainz track.</summary>
		public readonly track track;
		/// <summary>The MusicBrainz album.</summary>
		public readonly release release;
		/// <summary>The rank of this track.</summary>
		int rank;

		/// <summary>The constructor. Calculates rank.</summary>
		/// <param name="track">The MusicBrainz track.</param>
		/// <param name="release">The MusicBrainz album.</param>
		/// <param name="artistname">The ideal artist name.</param>
		/// <param name="trackname">The ideal track name.</param>
		public RankedTrack(track track, release release,
			string artistname, string trackname)
		{
			this.track = track;
			this.release = release;
			rank = track.score;
			if (release.type == "Album")
				rank += 15;
		}

		/// <summary>Compare this track to another.</summary>
		/// <param name="other">The other track to compare.</param>
		/// <returns>-1 if this is smaller, 0 if equal, 1 if bigger.</returns>
		public int CompareTo(RankedTrack other)
		{
			return rank.CompareTo(other.rank);
		}
	}
}
